package org.sczfdf.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author cgb
 */
public class CmdInfo {
    private String dir;
    private List<String> cmds = new ArrayList<>();
    private int watchInterval = 0;
    private String describe;

    public String getDir() {
        return dir;
    }

    public CmdInfo setDir(String dir) {
        this.dir = dir;
        return this;
    }

    public List<String> getCmds() {
        return cmds;
    }

    public CmdInfo setCmds(List<String> cmds) {
        this.cmds = cmds;
        return this;
    }

    public CmdInfo setCmd(String cmd) {
        cmds.add(cmd);
        return this;
    }

    public int getWatchInterval() {
        return watchInterval;
    }

    public void setWatchInterval(int watchInterval) {
        this.watchInterval = watchInterval;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CmdInfo cmdInfo = (CmdInfo) o;

        if (watchInterval != cmdInfo.watchInterval) return false;
        if (!Objects.equals(dir, cmdInfo.dir)) return false;
        return Objects.equals(cmds, cmdInfo.cmds);
    }

    @Override
    public int hashCode() {
        int result = dir != null ? dir.hashCode() : 0;
        result = 31 * result + (cmds != null ? cmds.hashCode() : 0);
        result = 31 * result + watchInterval;
        return result;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    @Override
    public String toString() {
        return "CmdInfo{" +
                "dir='" + dir + '\'' +
                ", cmds=" + cmds +
                ", watchInterval=" + watchInterval +
                ", describe='" + describe + '\'' +
                '}';
    }
}